package com.ruoyi.common.utils;
import java.math.BigDecimal;
import java.text.DecimalFormat;

public class PrcentageUtils {

    public String percent(int x, int y) {
        String percent = "";
        double xx = x * 100.0;
        double yy = y * 100.0;
        double zz = xx / yy;
        DecimalFormat df = new DecimalFormat("##0.00%");
        if(Math.abs(zz)<0.000000000001){
            percent = "0.00%";
        } else {
            percent = df.format(zz);
        }
        return percent;
    }


    public String percentTwo(int x, int y) {
        String percent = "";
        double xx = x * 100.0;
        double yy = y * 100.0;
        double zz = xx / yy;
        DecimalFormat df = new DecimalFormat("##0.00");
        if(Math.abs(zz)<0.000000000001){
            percent = "0.00";
        } else {
            percent = df.format(zz);
        }
        return percent;
    }

    public String percentThree(int x, int y) {
        String percent = "";
        double xx = x + 0.00;
        double yy = y * 0.00;
        double zz = xx / yy;
        DecimalFormat df = new DecimalFormat("##0.00");
        if(Math.abs(zz)<0.000000000001){
            percent = "0.00";
        } else {
            percent = df.format(zz);
        }
        return percent;
    }



    public static void main(String[] args) {

        long a = 3270;
        long b = 3272;

        Double d = a + 0.00;
        Double c = b + 0.00;

        DecimalFormat df = new DecimalFormat("##0.00");
        System.out.println(df.format(d / c * 100));

    }

}
